if (location.hash != '/home/') {
    history.replaceState({}, null, '#/home/')
}
$('body').show()

addEventListener('hashchange', function (event) {
    var oldName = new URL(event.oldURL).hash.split('/')[1]
    var newName = new URL(event.newURL).hash.split('/')[1]
    // console.log(oldName + '\t=>\t' + newName)
    $('.page-' + oldName).hide()
    $('.page-' + newName).show()
    var oldWebTitle = this.sessionStorage['oldWebTitle_' + newName]
    var oldWinTitle = this.sessionStorage['oldWinTitle_' + newName]
    var newWebTitle = this.sessionStorage['newWebTitle_' + oldName]
    var newWinTitle = this.sessionStorage['newWinTitle_' + oldName]
    oldWebTitle = oldWebTitle ? oldWebTitle : '鹏创网盘'
    oldWinTitle = oldWinTitle ? oldWinTitle : '鹏创网盘'
    newWebTitle = newWebTitle ? newWebTitle : '鹏创网盘'
    newWinTitle = newWinTitle ? newWinTitle : '鹏创网盘'
    if ((oldName == 'home' && newName == 'about') ||
        (oldName == 'home' && newName == 'about')) {
        $('.webTitle').html(newWebTitle)
        this.document.title = newWinTitle
    } else {
        $('.webTitle').html(oldWebTitle)
        this.document.title = oldWinTitle
    }
})

function changePage(pageName, webTitle, winTitle) {
    var oldName = location.hash.split('/')[1]
    sessionStorage['oldWebTitle_' + oldName] = $('.webTitle').html()
    sessionStorage['oldWinTitle_' + oldName] = document.title
    sessionStorage['newWebTitle_' + oldName] = webTitle
    sessionStorage['newWinTitle_' + oldName] = winTitle
    location.hash = '/' + pageName + '/'
}